//
//  订单提交Ctr.swift
//  Aiwei
//
//  Created by zhu xietong on 2017/11/8.
//  Copyright © 2017年 zhu xietong. All rights reserved.
//

import Foundation
import Eelay
import soapp


enum OrderExtra {
    static func extraRemarkKeys(data:NSMutableDictionary,index:Int)->[String]?{
        let ks = data.allKeys.map { (v) -> String in
            return "\(v)"
        }
        
        var extKeys:[String] = []
        for k in ks {
            if k.hasSuffix("_\(index)"){
                extKeys.append(k)
            }
        }
        if extKeys.count > 0{
            return extKeys
        }
        return nil
    }
    
    case bindzsyx
    
    static var cellSelector:TP.selector{
        get{
            return [
                "cellID<extra_title>":Extra.TitleCell.self,
                "cellID<extra_input>":Extra.InputCell.self
            ]
        }
        
    }
    func fields(index:Int)->[[String:Any]]{
            var fields = [[String:Any]]()
            switch self {
            case .bindzsyx:
                fields = [
                    [
                        "cellID":"extra_title","title":"会员卡绑定",
                    ],
                    [
                        "title":"众师云学账号".loc,
                        "cellID":"extra_input",
                        FK.fields:[
                            [
                                FK.placeholder:"请输入众师云学App登录手机号".loc,
                                FK.value:"",
                                FK.field:StrField(id: "extra_bindAccount_\(index)", defaultV: nil, need: true, hiden: false, rule:
                                    JoRule(reg: "^[\\s\\S]{1,100000}$", nil_msg: "请输入众师云学App登录手机号".loc, err_msg: "检查登录账号".loc))
                            ]
                        ],
                        ],
                    [
                        "title":"推广邀请账号".loc,
                        "cellID":"extra_input",
                        FK.fields:[
                            [
                                FK.placeholder:"请输入众师云学微信推广号".loc,
                                FK.value:"",
                                FK.field:StrField(id: "extra_inviteAccount_\(index)", defaultV: nil, need: true, hiden: false, rule:
                                    JoRule(reg: "^[\\s\\S]{1,100000}$", nil_msg: "请输入众师云学微信推广手机号".loc, err_msg: "检查推广号".loc))
                                
                            ]
                        ],
                    ]
                ]
            default:
                break
            }
            return fields
        
    }
}
